#include "led.h"

/**
  * @brief  ?????LED??
  * @param  ?
  * @retval ?
  */
void LED_Init(void)
{
  GPIO_InitTypeDef GPIO_InitStruct = {0};
  
  // ???LED??GPIO????
  LED_RED_GPIO_CLK_ENABLE();
  LED_GREEN_GPIO_CLK_ENABLE();
  LED_BLUE_GPIO_CLK_ENABLE();
  LED_YELLOW_GPIO_CLK_ENABLE();
  
  // ????LED??
  GPIO_InitStruct.Pin = LED_RED_PIN;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(LED_RED_GPIO_PORT, &GPIO_InitStruct);
  
  // ????LED??
  GPIO_InitStruct.Pin = LED_GREEN_PIN;
  HAL_GPIO_Init(LED_GREEN_GPIO_PORT, &GPIO_InitStruct);
  
  // ????LED??
  GPIO_InitStruct.Pin = LED_BLUE_PIN;
  HAL_GPIO_Init(LED_BLUE_GPIO_PORT, &GPIO_InitStruct);
  
  // ????LED??
  GPIO_InitStruct.Pin = LED_YELLOW_PIN;
  HAL_GPIO_Init(LED_YELLOW_GPIO_PORT, &GPIO_InitStruct);
  
  // ????????LED
  LED_RED_OFF;
  LED_GREEN_OFF;
  LED_BLUE_OFF;
  LED_YELLOW_OFF;
}

/**
  * @brief  4?LED??????
  * @param  ?
  * @retval ?
  * @note   ??LED???500ms,?????500ms
  */
void LED_Sync_Blink(void)
{
  // ??LED????
  LED_RED_ON;
  LED_GREEN_ON;
  LED_BLUE_ON;
  LED_YELLOW_ON;
  
  // ??500ms
  HAL_Delay(500);
  
  // ??LED????
  LED_RED_OFF;
  LED_GREEN_OFF;
  LED_BLUE_OFF;
  LED_YELLOW_OFF;
  
  // ??500ms
  HAL_Delay(500);
}

/**
  * @brief  ??LED????
  * @param  ?
  * @retval ?
  * @note   D1(?)?D3(?)???,D2(?)?D4(?)????
  *         ??????,???500ms
  */
void LED_Alternate_Blink(void)
{
  // ????,????
  LED_RED_ON;    // D1?
  LED_GREEN_OFF; // D2?
  LED_BLUE_ON;   // D3?
  LED_YELLOW_OFF;// D4?
  
  // ??500ms
  HAL_Delay(500);
  
  // ????,????
  LED_RED_OFF;   // D1?
  LED_GREEN_ON;  // D2?
  LED_BLUE_OFF;  // D3?
  LED_YELLOW_ON; // D4?
  
  // ??500ms
  HAL_Delay(500);
}
    